package com.wx.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface AuthorizationMapperDao {

	@Select("SELECT p1.menu_id FROM sys_user_menu AS p1 "
			+ "WHERE p1.user_id = #{user_id,jdbcType=INTEGER}")
	List<Integer> getMenusByUserId(@Param("user_id") Integer user_id);

	@Select("SELECT p1.menu_id FROM "
			+ "sys_role_menu AS p1 "
			+ "RIGHT JOIN sys_role AS p2 ON p1.role_id = p2.id "
			+ "RIGHT JOIN sys_user_role AS p3 ON p3.role_id = p2.id "
			+ "WHERE p3.user_id = #{user_id,jdbcType=INTEGER}")
	List<Integer> getMenusByUserRoles(@Param("user_id") Integer user_id);

	@Select("SELECT p1.role_id FROM sys_user_role AS p1 WHERE p1.user_id =  #{user_id,jdbcType=INTEGER}")
	List<Integer> getRoleIdByUserId(@Param("user_id") Integer user_id);
}
